package com.template.config.mybatisflex.listener;

import com.mybatisflex.annotation.UpdateListener;
import com.template.common.lang.BaseContext;
import com.template.domain.entity.base.BaseEntity;

import java.time.LocalDateTime;

/**
 * 使用mybatis flex修改数据时自动填充
 */
public class MyUpdateListener implements UpdateListener {
    @Override
    public void onUpdate(Object object) {
        BaseEntity baseEntity = (BaseEntity) object;
        baseEntity.setUpdateTime(LocalDateTime.now());
        baseEntity.setUpdateUser(BaseContext.getCurrentId());
    }
}
